# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Corrado Primier <bardo@aur.archlinux.org>

pkgname=rtkit
pkgver=0.13
pkgrel=1
pkgdesc="Realtime Policy and Watchdog Daemon"
arch=(x86_64)
url="https://github.com/heftig/rtkit"
license=(GPL3 'custom:BSD')
depends=(dbus polkit systemd)
makedepends=(git meson vim)
_commit=b9169402fe5e82d20efb754509eb0b191f214599  # tags/v0.13^0
source=("git+https://github.com/heftig/rtkit?signed#commit=$_commit")
sha256sums=('SKIP')
validpgpkeys=('8218F88849AAC522E94CF470A5E9288C4FA415FA')  # Jan Alexander Steffens (heftig)

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  arch-meson $pkgname build -D installed_tests=false
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  DESTDIR="$pkgdir" meson install -C build

  echo 'u rtkit 133 "RealtimeKit" /proc' |
    install -Dm644 /dev/stdin "$pkgdir/usr/lib/sysusers.d/$pkgname.conf"

  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 $pkgname/LICENSE
  sed -ne '4,25p' $pkgname/rtkit.c |
    install -Dm644 /dev/stdin "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
